package com.ruoyi.qyj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.qyj.domain.TbRecordInfo;
import com.ruoyi.qyj.service.ITbRecordInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 信息互通Controller
 * 
 * @author yellow
 * @date 2023-09-14
 */
@RestController
@RequestMapping("/qyj/info")
public class TbRecordInfoController extends BaseController
{
    @Autowired
    private ITbRecordInfoService tbRecordInfoService;

    /**
     * 查询信息互通列表
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbRecordInfo tbRecordInfo)
    {
        startPage();
        List<TbRecordInfo> list = tbRecordInfoService.selectTbRecordInfoList(tbRecordInfo);
        return getDataTable(list);
    }

    /**
     * 导出信息互通列表
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:export')")
    @Log(title = "信息互通", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbRecordInfo tbRecordInfo)
    {
        List<TbRecordInfo> list = tbRecordInfoService.selectTbRecordInfoList(tbRecordInfo);
        ExcelUtil<TbRecordInfo> util = new ExcelUtil<TbRecordInfo>(TbRecordInfo.class);
        util.exportExcel(response, list, "信息互通数据");
    }

    /**
     * 获取信息互通详细信息
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(tbRecordInfoService.selectTbRecordInfoByRecordId(recordId));
    }

    /**
     * 新增信息互通
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:add')")
    @Log(title = "信息互通", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRecordInfo tbRecordInfo)
    {
        return toAjax(tbRecordInfoService.insertTbRecordInfo(tbRecordInfo));
    }

    /**
     * 修改信息互通
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:edit')")
    @Log(title = "信息互通", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbRecordInfo tbRecordInfo)
    {
        return toAjax(tbRecordInfoService.updateTbRecordInfo(tbRecordInfo));
    }

    /**
     * 删除信息互通
     */
    @PreAuthorize("@ss.hasPermi('qyj:info:remove')")
    @Log(title = "信息互通", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(tbRecordInfoService.deleteTbRecordInfoByRecordIds(recordIds));
    }
}
